<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <script type="text/javascript" src="javascripts/jquery-1.11.0.min.js"></script>
  <script src="scripts/layui/lay/modules/laydate.js"></script> 
 <script src="scripts/layui/layui.js" charset="utf-8"></script>
 <script src="scripts/js/bootstrap.min.js"></script>

  <link rel="stylesheet" href="scripts/css/bootstrap.min.css" />
 <link rel="stylesheet" href="scripts/layui/css/layui.css"  media="all">
<title>物品管理</title>
</head>
<body>
<div id="content">
	<div><a href="#">行政管理</a>>物品管理</div>
 	<!-- 选项卡 -->
	<div class="layui-tab">
		<ul class="layui-tab-title">
			<li class="layui-this">物品借还</li>
			<li>物品管理</li>
			<li>借出物品详情</li>
		</ul>
		<div class="layui-tab-content">
			<!-- 物品借还-->
			<div class="layui-tab-item layui-show">
			
				<table  class="layui-table" lay-size="sm"  lay-skin="nob" style="width:952px">
					<tr>
						<td>物品编号：<input type="text" id="quoo_no"></td>
						<td>物品名称：<input type="text" id="quoo_name"></td>
						<td>物品规格：<input type="text" id="quoo_specifical"></td>
						<td>所属分类：
							<select id="quoo_category">
								<option value="0">--选择分类--</option>
								<option v-for="ct in categorys" v-bind:value=ct.category_id>{{ct.category_name}}</option>
							</select>
						</td>
						<td><button type="button" v-on:click="queryoobycondition(1)"  class="layui-btn layui-btn-sm">查询</button></td>
					</tr>
				</table>
			
				<div style="border-top:1px black solid;border-bottom:1px black solid;">
				<template>
					<p v-if="officeobjects.length===0" style="text-align:center">暂无物品信息！</p>
					<table  class="layui-table" v-else>
					<tr id="meetingtitle">
					<th style="text-align:center">序号</th>
					<th style="text-align:center">物品编号</th>
					<th style="text-align:center">物品名称</th>
					<th style="text-align:center">物品规格</th>
					<th style="text-align:center">库存</th>
					<th style="text-align:center">所属分类</th>
					<th style="text-align:center">操作</th>
					</tr>
					<tr v-for="(oo,index) in officeobjects">
					<td name="oo_id" style="text-align:center">
					 {{index+1}}
					</td>
					<td name="oo_no" style="text-align:center">{{oo.oo_no}}</td>
					<td name="oo_name" style="text-align:center">{{oo.oo_name}}</td>
					<td name="oo_specifical" style="text-align:center">{{oo.oo_specifical}}</td>
					<td name="oo_store" style="text-align:center">{{oo.oo_store}}</td>
					<td name="oo_categoryid" style="text-align:center">{{oo.cg.category_name}}</td>
					<input type="hidden" v-bind:value=oo.cg.category_id>
					<td style="text-align:center">
						<a href="#" v-on:click="rentofficeobject($event,oo.oo_id)">借出</a> &nbsp;
						<a href="#" v-on:click="sendoo($event,oo.oo_id)">归还</a>
					</td>
					</tr>
					</table>
					</template>
					<div id="oopages" style="width:500px;margin:0 auto;"></div>
				</div>
			</div>
			<!-- 物品管理-->
			<div class="layui-tab-item">
				<table  class="layui-table" lay-size="sm"  lay-skin="nob" style="width:600px">
					<tr>
						
						<td>物品名称：<input type="text" id="quoomanage_name"></td>
						<td>所属分类：
							<select id="quoomanage_category">
								<option value="0">--选择分类--</option>
								<option v-for="ct in categorys" v-bind:value=ct.category_id>{{ct.category_name}}</option>
							</select>
						</td>
						<td><button type="button" v-on:click="queryoomanagebycondition(1)" class="layui-btn layui-btn-sm">查询</button></td>
						<td><button type="button" v-on:click="insertoo" class="layui-btn layui-btn-sm">添加物品</button></td>
						<td><button type="button" v-on:click="insertcategory" class="layui-btn layui-btn-sm">添加分类</button></td>
					</tr>
				</table>
			
				<div style="border-top:1px black solid;border-bottom:1px black solid;">
				<template>
					<p v-if="officeobjectsmanage.length===0" style="text-align:center">暂无物品信息！</p>
					<table  class="layui-table" v-else>
					<tr id="meetingtitle">
					<th style="text-align:center">序号</th>
					<th style="text-align:center">物品编号</th>
					<th style="text-align:center">物品名称</th>
					<th style="text-align:center">物品规格</th>
					<th style="text-align:center">库存</th>
					<th style="text-align:center">所属分类</th>
					<th style="text-align:center">操作</th>
					</tr>
					<tr v-for="(oo,index) in officeobjectsmanage">
					<td name="oo_id" style="text-align:center">
					 {{index+1}}
					</td>
					<td name="oo_no" style="text-align:center">{{oo.oo_no}}</td>
					<td name="oo_name" style="text-align:center">{{oo.oo_name}}</td>
					<td name="oo_specifical" style="text-align:center">{{oo.oo_specifical}}</td>
					<td name="oo_store" style="text-align:center">{{oo.oo_store}}</td>
					<td name="oo_categoryid" style="text-align:center">{{oo.cg.category_name}}</td>
					<input type="hidden" v-bind:value=oo.cg.category_id>
					<td name="oo_store" style="text-align:center">
						<a href="#" v-on:click="updateofficeobject($event,oo.oo_id)">修改</a> &nbsp;
						<a href="#" v-on:click="deleteoo($event,oo.oo_id)">删除</a>
					</td>
					</tr>
					</table>
					</template>
					<div id="oomanagepages" style="width:500px;margin:0 auto;"></div>
				</div>
			</div>
			<!-- 借出物品详情 -->
			<div class="layui-tab-item">
				
				<table  class="layui-table" lay-size="sm" lay-skin="nob" style="width:952px;">
						<tr>
							<td>物品名称：<input type="text" id="quooa_name"></td>
							<td>物品规格：<input type="text" id="quooa_specifical"> 所属分类：
								<select id="quooa_category">
									<option value="0">--选择分类--</option>
									<option v-for="ct in categorys" v-bind:value=ct.category_id>{{ct.category_name}}</option>
								</select>
							</td>
							</tr><tr>
							<td>领用人：<input type="text" id="quooa_username"></td>
							
							<td>时间：
							<input type="text" id="quooa_starttime" class="ctime">至
							<input type="text" id="quooa_stoptime" class="ctime">
							</td>
							<td><button type="button" v-on:click="queryooabycondition(1)" class="layui-btn layui-btn-sm">查询</button></td>
						</tr>
				</table>
				
				<div style="border-top:1px black solid;border-bottom:1px black solid;">
				<template>
						<p v-if="ooalist.length===0" style="text-align:center">暂无物品信息！</p>
						<table  class="layui-table" v-else>
						<tr id="meetingtitle">
						<th style="text-align:center">序号</th>
						<th style="text-align:center">物品编号</th>
						<th style="text-align:center">物品名称</th>
						<th style="text-align:center">物品规格</th>
						<th style="text-align:center">所属分类</th>
						<th style="text-align:center">领用时间</th>
						<th style="text-align:center">领用人</th>
						</tr>
						<tr v-for="(ooa,index) in ooalist">
						<td name="ooa_id" style="text-align:center">
						 {{index+1}}
						</td>
						<td name="ooa_no" style="text-align:center">{{ooa.oo.oo_no}}</td>
						<td name="ooa_name" style="text-align:center">{{ooa.oo.oo_name}}</td>
						<td name="ooa_specifical" style="text-align:center">{{ooa.oo.oo_specifical}}</td>
						<td name="ooa_store" style="text-align:center">{{ooa.oo.cg.category_name}}</td>
						<td name="ooa_categoryid" style="text-align:center">{{ooa.ooa_applytime}}</td>
						<td name="ooa_store" style="text-align:center">{{ooa.ooa_username}}</td>
						</tr>
						</table>
					</template>
					<div id="ooapages" style="width:500px;margin:0 auto;"></div>
					</div>
			</div>
		</div>
	</div>
	
	<!-- 添加分类弹出层 -->
	<div class="modal fade" id="insertcategory" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">添加分类</div>
                <div class="modal-body">
                <table class="layui-table" lay-skin="nob">
                <tr>
                 <td>分类名称：</td>
                 <td><input type="text" id="insertcategory_name"></td>
                 </tr>
                 </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary" data-dismiss="modal" v-on:click="insertctg()">提交</button>
                </div>
            </div>
        </div>
    </div>
	<!-- 添加物品弹出层 -->
	<div class="modal fade" id="insertoo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">添加物品</div>
                <div class="modal-body">
                <table class="layui-table" lay-skin="nob">
                <tr>
                 <td>物品编号：</td>
                 <td><input type="text" id="insertoo_no"></td>
                 </tr>
                <tr>
                 <td>物品名：</td>
                 <td><input type="text" id="insertoo_name"></td>
                 </tr>
                  <tr>
                 <td>规格型号：</td>
                 <td><input type="text" id="insertoo_specifical"></td>
                 </tr>
                 <tr>
                 <td>所属分类：</td>
                 <td>
						<select id="insertoo_category">
							<option value="0">--选择分类--</option>
							<option v-for="ct in categorys" v-bind:value=ct.category_id>{{ct.category_name}}</option>
						</select>
				 </td>
                 </tr>
                 <tr>
                 <td>数量：</td>
                 <td><input type="text" id="insertoo_store"/></td>
                 </tr>
                 </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary" data-dismiss="modal" v-on:click="insertofficeobject()">提交</button>
                </div>
            </div>
        </div>
    </div>
	<!-- 借用弹出层 -->
	<div class="modal fade" id="rentoo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">领用物品</div>
                <div class="modal-body">
                <table class="layui-table" lay-skin="nob">
                <tr>
                 <td>物品编号：</td>
                 <td><span id="rentooa_oono"></span></td>
                 </tr>
                <tr>
                 <td>物品名：</td>
                 <td><span id="rentooa_ooname"></span></td>
                 </tr>
                  <tr>
                 <td>规格型号：</td>
                 <td><span id="rentooa_oospecifical"></span></td>
                 </tr>
                 <tr>
                 <td>领用数量：</td>
                 <td><input type="text" id="rentooa_oonum"/><input type="hidden" id="rentooa_ooid"/>
              		 <input type="hidden" id="rentooa_oostore"/>
                 </td>
                 </tr>
                 <tr>
                 <td>领用人：</td>
                 <td><input type="text" id="rentooa_username"/></td>
                 </tr>
                 </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary" data-dismiss="modal" id="rentoo" v-on:click="rentoo()">提交</button>
                </div>
            </div>
        </div>
    </div>
    <!-- 修改弹出层 -->
	<div class="modal fade" id="updateoo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">修改物品</div>
                <div class="modal-body">
                <table class="layui-table" lay-skin="nob">
                <tr>
                 <td>物品编号：</td>
                 <td><input type="text" id="updateoo_no"/></td>
                 </tr>
                <tr>
                 <td>物品名：</td>
                 <td><input type="text" id="updateoo_name"/></td>
                 </tr>
                  <tr>
                 <td>规格型号：</td>
                 <td><input type="text" id="updateoo_specifical"/></td>
                 </tr>
                 <tr>
                 <td>数量：</td>
                 <td><input type="text" id="updateoo_store"/><input type="hidden" id="updateoo_id"/>
                 </td>
                 </tr>
                 <tr>
                 <td>所属分类：</td>
                 <td>
						<select id="updateoo_category">
							<option value="0">--选择分类--</option>
							<option v-for="ct in categorys" v-bind:value=ct.category_id>{{ct.category_name}}</option>
						</select></td>
                 </tr>
                 </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary" data-dismiss="modal" id="updateoo" v-on:click="updateoo()">提交</button>
                </div>
            </div>
        </div>
    </div>
    <!-- 归还弹出层 -->
	<div class="modal fade" id="sendoo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">归还物品</div>
                <div class="modal-body">
                <table class="layui-table" lay-skin="nob">
                <tr>
                 <td>物品编号：</td>
                 <td><span id="sendooa_oono"></span></td>
                 </tr>
                <tr>
                 <td>物品名：</td>
                 <td><span id="sendooa_ooname"></span></td>
                 </tr>
                  <tr>
                 <td>规格型号：</td>
                 <td><span id="sendooa_oospecifical"></span></td>
                 </tr>
                 <tr>
                 <td>归还人：</td>
                 <td>
 					<select id="sendooa_username" @change="changemodel" v-model="uname">
 						<option value=""  selected="selected"></option>
						<option v-for="sooa in sendofficeobjects" v-bind:value=sooa.ooa_oonum v-bind:name=sooa.ooa_username v-bind:id=sooa.ooa_id v-bind:class=sooa.ooa_applytime>
						{{sooa.ooa_username}}  借出时间：{{sooa.ooa_applytime}}
						
						</option>
					</select>
				</td>
                 </tr>
                 <tr>
                 <td>归还数量：</td>
                 <td><input type="text" id="sendooa_oonum" v-model="num"/><input type="hidden" id="sendooa_ooid"/></td>
                 </tr>
                 
                 </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary" data-dismiss="modal" id="rentoo" v-on:click="sendofficeobject()">提交</button>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="scripts/js/vue.js"></script>
<script type="text/javascript">
$(function(){

var vm = new Vue({
    el: "#content",
    data: {
      categorys:[],
      officeobjects:[],
      sendofficeobjects:[],
      officeobjectsmanage:[],
      ooalist:[],
      num:[],
      uname:[]
      
    },
	methods:{
			//查询所有分类
			querycategory:function(){
				var _self=this
				$.ajax({
					url:"../querycategory",
					type:"post",
					dataType:"json",
					success:function(result){
						_self.categorys=result;
						console.log(result)
					}
				})
			},
			//按条件查询物品
			queryoobycondition:function(curr){
				var _self=this
				var oo_no=$("#quoo_no").val();
				var oo_name=$("#quoo_name").val();
				var oo_specifical=$("#quoo_specifical").val();
				var oo_categoryid=$("#quoo_category option:selected").val();
				console.log("oo_no="+oo_no+" oo_name="+oo_name+" oo_specifical="+oo_specifical+" oo_categoryid="+oo_categoryid)
				$.ajax({
					url:"../queryoobycondition",
					data:{curr:curr,oo_no:oo_no,oo_name:oo_name,oo_specifical:oo_specifical,oo_categoryid:oo_categoryid},
					type:"post",
					dataType:"json",
					success:function(result){
						_self.officeobjects=result.oolist;
						console.log(result)
						 layui.use(['laypage', 'layer'], function(){
					    	   var laypage = layui.laypage
					    	   ,layer = layui.layer;
					    	   //总页数低于页码总数
					    	   laypage.render({
					    	     elem: 'oopages'
					    	     ,count: result.totle //数据总数
					    	     ,limit:10
					    	    ,curr:curr
					    	   , layout: ['count', 'prev', 'page', 'next', 'skip']
					    	     ,jump: function(obj, first){
					    	         if(!first){
					    	        	 vm.queryoobycondition(obj.curr)
					    	         }
					    	       }
					    	   })
					       });
					}
				})
			},
			//管理物品按条件查询物品
			queryoomanagebycondition:function(curr){
				var _self=this
				var oo_name=$("#quoomanage_name").val();
				var oo_categoryid=$("#quoomanage_category option:selected").val();
				console.log("oo_name="+oo_name+" oo_categoryid="+oo_categoryid)
				$.ajax({
					url:"../queryoobycondition",
					data:{curr:curr,oo_name:oo_name,oo_categoryid:oo_categoryid},
					type:"post",
					dataType:"json",
					success:function(result){
						_self.officeobjectsmanage=result.oolist;
						console.log(result)
						 layui.use(['laypage', 'layer'], function(){
					    	   var laypage = layui.laypage
					    	   ,layer = layui.layer;
					    	   //总页数低于页码总数
					    	   laypage.render({
					    	     elem: 'oomanagepages'
					    	     ,count: result.totle //数据总数
					    	     ,limit:10
					    	    ,curr:curr
					    	   , layout: ['count', 'prev', 'page', 'next', 'skip']
					    	     ,jump: function(obj, first){
					    	         if(!first){
					    	        	 vm.queryoomanagebycondition(obj.curr)
					    	         }
					    	       }
					    	   })
					       });
					}
				})
			},
			//按条件查询借出的物品
			queryooabycondition:function(curr){
				var _self=this
				var ooa_username=$("#quooa_username").val();
				var oo_name=$("#quooa_name").val();
				var oo_specifical=$("#quooa_specifical").val();
				var oo_categoryid=$("#quooa_category option:selected").val();
				var ooa_starttime=$("#quooa_starttime").val();
				var ooa_stoptime=$("#quooa_stoptime").val();
				console.log("ooa_username="+ooa_username+" oo_name="+oo_name+" oo_specifical="+oo_specifical+" oo_categoryid="+oo_categoryid)
				$.ajax({
					url:"../queryooabycondition",
					data:{curr:curr,ooa_username:ooa_username,oo_name:oo_name,oo_specifical:oo_specifical,oo_categoryid:oo_categoryid,ooa_starttime:ooa_starttime,ooa_stoptime:ooa_stoptime},
					type:"post",
					dataType:"json",
					success:function(result){
						_self.ooalist=result.ooalist;
						console.log(result.ooalist)
						 layui.use(['laypage', 'layer'], function(){
					    	   var laypage = layui.laypage
					    	   ,layer = layui.layer;
					    	   //总页数低于页码总数
					    	   laypage.render({
					    	     elem: 'ooapages'
					    	     ,count: result.totle //数据总数
					    	     ,limit:10
					    	    ,curr:curr
					    	   , layout: ['count', 'prev', 'page', 'next', 'skip']
					    	     ,jump: function(obj, first){
					    	         if(!first){
					    	        	 vm.queryooabycondition(obj.curr)
					    	         }
					    	       }
					    	   })
					       });
					}
				})
			},
			changemodel:function(){
				this.num=this.uname
			},
			//租用弹出框显示
			rentofficeobject:function(event,id){
				var el=event.currentTarget;
				var oono=$(el).parent().siblings("td[name='oo_no']").html();
				var ooname=$(el).parent().siblings("td[name='oo_name']").html();
				var oo_store=$(el).parent().siblings("td[name='oo_store']").html();
				var oospecifical=$(el).parent().siblings("td[name='oo_specifical']").html();
				console.log("ooname"+ooname)
				$("#rentooa_ooid").val(id);
				$("#rentooa_oono").html(oono);
				$("#rentooa_ooname").html(ooname);
				$("#rentooa_oostore").val(oo_store);
				$("#rentooa_oospecifical").html(oospecifical);
				$("#rentoo").modal("show");
			},
			//归还弹出框显示
			sendoo:function(event,id){
				var el=event.currentTarget;
				var _self=this
				this.num=""
				this.uname=""
				var oono=$(el).parent().siblings("td[name='oo_no']").html();
				var ooname=$(el).parent().siblings("td[name='oo_name']").html();
				var oospecifical=$(el).parent().siblings("td[name='oo_specifical']").html();
				//查询该物品的所有领用人和领用数量
				$.ajax({
					url:"../sendoo",
					data:{ooa_ooid:id},
					type:"post",
					dataType:"json",
					success:function(result){
						console.log(result)
						_self.sendofficeobjects=result
					}
				})
				$("#sendooa_ooid").val(id);
				$("#sendooa_oono").html(oono);
				$("#sendooa_ooname").html(ooname);
				$("#sendooa_oospecifical").html(oospecifical);
				$("#sendoo").modal("show");
			},
			//修改物品弹出框显示
			updateofficeobject:function(event,id){
				var el=event.currentTarget;
				var oono=$(el).parent().siblings("td[name='oo_no']").html();
				var ooname=$(el).parent().siblings("td[name='oo_name']").html();
				var oostore=$(el).parent().siblings("td[name='oo_store']").html();
				var oospecifical=$(el).parent().siblings("td[name='oo_specifical']").html();
				var oocategoryid=$(el).parent().siblings("input[type='hidden']").val();
				console.log("ooname"+ooname)
				$("#updateoo_id").val(id);
				$("#updateoo_no").val(oono);
				$("#updateoo_name").val(ooname);
				$("#updateoo_store").val(oostore);
				$("#updateoo_specifical").val(oospecifical);
				$("#updateoo_category option").each(function(){
					 if (parseInt(oocategoryid) == parseInt($(this).val())) {
						 $(this).attr("selected","selected")
					} 
					});
				$("#updateoo").modal("show");
			},
			//借用物品
			rentoo:function(){
				var ooa_ooid=$("#rentooa_ooid").val();
				var ooa_oonum=$("#rentooa_oonum").val();
				var ooa_oostore=$("#rentooa_oostore").val();
				var ooa_username=$("#rentooa_username").val();
				console.log(ooa_oostore)
				if(parseInt(ooa_oonum)>parseInt(ooa_oostore)){
					alert("库存不足！");
					return;
				}else{
					$.ajax({
						url:"../rentoo",
						data:{ooa_ooid:ooa_ooid,ooa_oonum:ooa_oonum,ooa_username:ooa_username},
						type:"post",
						dataType:"json",
						success:function(result){
							if(result!=0){
								alert("租借成功！")
								vm.queryoobycondition(1)
								vm.queryooabycondition(1)
								vm.queryoomanagebycondition(1)
								return
							}
							console.log(result)
						}
					})
				}
			},
			//添加物品弹出框
			insertoo:function(){
				$("#insertoo").modal("show");
			},
			//添加分类弹出框
			insertcategory:function(){
				$("#insertcategory").modal("show");
			},
			//添加分类
			insertctg:function(){
				var category_name=$("#insertcategory_name").val();
				$.ajax({
					url:"../insertcategory",
					data:{category_name:category_name},
					type:"post",
					dataType:"json",
					success:function(result){
						if(result!=0){
							alert("添加成功！")
							vm.queryoobycondition(1)
							vm.queryooabycondition(1)
							vm.queryoomanagebycondition(1)
							return
						}
					}
				})
			},
			
			//添加物品
			insertofficeobject:function(){
				var oo_no=$("#insertoo_no").val();
				var oo_name=$("#insertoo_name").val();
				var oo_specifical=$("#insertoo_specifical").val();
				var oo_categoryid=$("#insertoo_category option:selected").val();
				var oo_store=$("#insertoo_store").val();
				$.ajax({
					url:"../insertoo",
					data:{oo_no:oo_no,oo_name:oo_name,oo_specifical:oo_specifical,oo_categoryid:oo_categoryid,oo_store:oo_store},
					type:"post",
					dataType:"json",
					success:function(result){
						if(result!=0){
							alert("添加成功！")
							vm.queryoobycondition(1)
							vm.queryooabycondition(1)
							vm.queryoomanagebycondition(1)
							return
						}
					}
				})
			},
			//修改物品
			updateoo:function(){
				var oo_id=$("#updateoo_id").val();
				var oo_no=$("#updateoo_no").val();
				var oo_name=$("#updateoo_name").val();
				var oo_specifical=$("#updateoo_specifical").val();
				var oo_categoryid=$("#updateoo_category option:selected").val();
				var oo_store=$("#updateoo_store").val();
				$.ajax({
					url:"../updateoo",
					data:{oo_id:oo_id,oo_no:oo_no,oo_name:oo_name,oo_specifical:oo_specifical,oo_categoryid:oo_categoryid,oo_store:oo_store},
					type:"post",
					dataType:"json",
					success:function(result){
						if(result!=0){
							alert("修改成功！")
							vm.queryoobycondition(1)
							vm.queryooabycondition(1)
							vm.queryoomanagebycondition(1)
							return
						}
					}
				})
			},
			//删除物品
			deleteoo:function(event,id){
				var el=event.currentTarget;
				$.ajax({
					url:"../deleteoo",
					data:{oo_id:id},
					type:"post",
					dataType:"json",
					success:function(result){
						if(result!=0){
							alert("删除成功！")
							vm.queryoobycondition(1)
							vm.queryooabycondition(1)
							vm.queryoomanagebycondition(1)
							return
						}
					}
				})
			},
			//归还物品
			sendofficeobject:function(){
				var ooa_id=$("#sendooa_username option:selected").attr("id");
				var ooa_oonum=$("#sendooa_oonum").val();
				var ooa_ooid=$("#sendooa_ooid").val();
				var ooa_username=$("#sendooa_username option:selected").attr("name");
				var ooa_applytime=$("#sendooa_username option:selected").attr("class");
				console.log("ooa_id="+ooa_id+"ooa_ooid="+ooa_ooid+" ooa_oonum="+ooa_oonum+" ooa_username="+ooa_username+" ooa_applytime="+ooa_applytime)
				$.ajax({
					url:"../sendofficeobject",
					data:{ooa_id:ooa_id,ooa_ooid:ooa_ooid,ooa_oonum:ooa_oonum,ooa_username:ooa_username,ooa_applytime:ooa_applytime},
					type:"post",
					dataType:"json",
					success:function(result){
						if(result!=0){
							alert("归还成功！")
							vm.queryoobycondition(1)
							vm.queryooabycondition(1)
							vm.queryoomanagebycondition(1)
							return
						}
						console.log(result)
					}
				})
			},
		}
	});
	vm.querycategory(),
	vm.queryoobycondition(1),
	vm.queryoomanagebycondition(1),
	vm.queryooabycondition(1),
	
	 lay('.ctime').each(function(){
	       laydate.render({
	    	   elem: this
	    	   ,type: 'datetime'
	    	   ,trigger: 'click'
	    	   ,format:'yyyy-MM-dd HH:mm:ss'
	    	 })
	       });
	
});

layui.use('element', function(){
    	   var $ = layui.jquery
    	   ,element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
    	   //触发事件
    	   var active = {
    	   tabChange: function(){
    	       //切换到指定Tab项
    	       element.tabChange('demo', '22'); //切换到：用户管理
    	     }
    	   };
    	   $('.site-demo-active').on('click', function(){
    	     var othis = $(this), type = othis.data('type');
    	     active[type] ? active[type].call(this, othis) : '';
    	   });
    	 });
</script>
</html>